package com.zz.ecommerce.logisticsManage.search;

import com.zz.ecommerce.common.GridRequest;
import com.zz.ecommerce.common.GridResult;
import com.zz.ecommerce.common.constants.TableConstants;
import com.zz.ecommerce.pojo.CbecLogistics;
import com.zz.ecommerce.pojo.CbecLogisticsStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * 物流中心查询功能
 */
@Controller
@RequestMapping("/logisticsMgn/search")
public class LogisticsMgnController {
    private static final Logger LOG = LoggerFactory.getLogger(LogisticsMgnController.class);


    @Autowired
    private LogisticsMgnDao logisticsMgnDao;
    @Autowired
    private LogisticsStatusMgnDao logisticsStatusMgnDao;


    @RequestMapping(value = "index", method = {RequestMethod.GET, RequestMethod.POST})
    public String index() {
        return "logisticsManage/search/index";
    }

    @RequestMapping("/queryOrderList")
    @ResponseBody
    public GridResult queryOrderList(CbecLogistics cbecLogistics, GridRequest request, HttpSession session) {
//        orderHead.setOrgId(SessionUtil.getOrganizationId(session));
        List<CbecLogistics> tPersonalIdentities = logisticsMgnDao.page(TableConstants.CBEC_LOGISTICS, cbecLogistics,
                request.getStart(), request.getEnd(), request.getSortOrder());
        return new GridResult<CbecLogistics>(tPersonalIdentities, request, logisticsMgnDao.count(TableConstants.CBEC_LOGISTICS, cbecLogistics));
    }

    @RequestMapping("/showDetail")
    public String showDetail(CbecLogisticsStatus cbecLogisticsStatusList, ModelMap modelMap) {
        List<CbecLogisticsStatus> cbecLogisticsStatuses = logisticsStatusMgnDao.queryAll(TableConstants.CBEC_LOGISTICS_STATUS, cbecLogisticsStatusList, " logistics_date DESC ");
        modelMap.addAttribute("cbecLogisticsStatuses", cbecLogisticsStatuses);
        return "searchManage/logsitics/logistics_detail";
    }

}
